//
//  ZYInDoorView.m
//  YiLin
//
//  Created by Zyark on 2018/6/4.
//  Copyright © 2018年 Zyark. All rights reserved.
//

#import "ZYOutDoorView.h"
#import "ZYDevice.h"

#define LEFT 30
#define MARGIN 15
@interface ZYOutDoorView()

/**
 温度
 */
@property(nonatomic,strong) UILabel *temperatureLabel;

/**
 湿度
 */
@property(nonatomic,strong) UILabel *humidityLabel;

@end

@implementation ZYOutDoorView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

-(void)setup{
    _temperatureLabel = [self setupLabel];
    _humidityLabel = [self setupLabel];;

    _humidityLabel.left = LEFT;
    _humidityLabel.top = MARGIN;
    
    _temperatureLabel.right = self.width - LEFT;
    _temperatureLabel.top = MARGIN;
}

-(UILabel *)setupLabel{
    UILabel *label = [[UILabel alloc] init];
    label.width = self.width / 2  - LEFT;
    label.height = 15;
    label.font = [UIFont systemFontOfSize:14];
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = kDeviceLabelColor;
    [self addSubview:label];
    return label;
}

-(UIView *)setupFilterBgView{
    UIView *view = [[UIView alloc] init];
    view.height = 20;
    view.width = self.width / 2 - LEFT;
    view.backgroundColor = [UIColor whiteColor];
    view.layer.cornerRadius = 3;
    view.layer.masksToBounds = YES;
    [self addSubview:view];
    return view;
}

-(void)setDevice:(ZYDevice *)device{
    _device = device;
    ZYChangeLanguage *language = [ZYChangeLanguage sharedZYChangeLanguage];
    _humidityLabel.text = [NSString stringWithFormat:@"%@：%@%%",[language getStringByKey:LC_HOME_MAIN_HUMIDITY],device.outHumidity];
    _temperatureLabel.text = [NSString stringWithFormat:@"%@：%@℃",[language getStringByKey:LC_HOME_MAIN_TEMPERATURE],device.outTemperature];
}

@end
